﻿/*
级数求和 
Time Limit:1000MS  Memory Limit:32768K

  
Description:
求下列级数的和： 1 + x - x^2/2! + x^3/3! - ... (-1)^(n+1)*x^n/n!

Input:
输入数据含有不多于50个的浮点数x(0.0≤x≤5.0) 
Output:
对于每个x，输出其级数和，所有绝对值小于10的-6次方的数值不应加入级数和中，每个x的计算结果应占单独一行。其格式见样本输出 
Sample Input:
2.1 3.2
Sample Output:
x=2.100000, sum=1.877544
x=3.200000, sum=1.959238
*/
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
	for (double x; cin>>x;)
	{
		double sum=1.0, item=x;
		int n=2;
		while (fabs(item)>1e-6)
		{
			sum+=item;
			item*=-x/(double)n;	
			++n;
		}
		cout<<fixed<<"x="<<x<<", sum="<<sum<<endl;
	}
	return EXIT_SUCCESS;
}
/*
int main()
{
	for (double x; cin>>x;)
	{
		
		double progression=1.0, item=1.0;
		for (unsigned n=1; ; n++)
		{
			if(fabs(item)<1e-6)
			{
				cout.setf(ios::fixed|ios::showpoint);
				cout.precision(6);
				cout<<"x="<<x<<", sum=";
				cout.precision(6);
				cout<<progression<<endl;
				break;
			}
			item=item*x/(double)n;
			progression+=item;
			item=-item;
		}
		
	}
	return EXIT_SUCCESS;
}
*/